cc.Class({
    extends: cc.Component,

    properties: {
        prefabPrentNode: cc.Node,
        prefabs: [cc.Prefab],
        _nodeArray: [cc.Node],
    },
    editor: {
        menu: 'ExtendUI/ClickLinkPrefab'
    },

    // use this for initialization
    onLoad: function () {
        this.node.on('click', this._onClick, this);
        this.node.on('click_cancel', this._onClickCancel, this);
    },

    _onClick: function() {
        for (var i = 0; i < this.prefabs.length; i++) {
            var node = this.prefabs[i].newTo(this.prefabPrentNode);
            this._nodeArray.push(node);
        }
    },

    _onClickCancel: function() {
        for (var i = 0; i < this._nodeArray.length; i++) {
            this._nodeArray[i].destroy();
        }
        this._nodeArray = [];
    }
});
